<%@taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page language="java" pageEncoding="UTF-8" %>


<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8">
    <link href="${pageContext.request.contextPath}/css/main.css" rel="stylesheet">
</head>
<style type="text/css">
    .abj{
        padding-left: 24px;
    }
</style>
<body>
<!-- 栏目管理 -->
<div class="AccountManagement_c" id="ColumnManagement_c">
    <h3>栏目管理
        <div class="amcl fr">
            <input type="text" placeholder="用户名" class="fl" name="">
            <div class="search fl"><img src="${pageContext.request.contextPath}/images/search.png"></div>
        </div>
    </h3>
    <div class="AM_ct text_center">
        <div class="AM_ct_in">
            <div class="add_btn df_btn fl" id="add_column_btn">添加</div>
        </div>
    </div>

    <div class="list">
        <ul class="list_h">
            <li class="b20"><label><span>栏目名称</span></li>
            <li class="b20"><label>序号</label></li>
            <li class="b20"><label>创建时间</label></li>
            <li class="b20"><label>更新时间</label></li>
        </ul>
        <div class="list_b_c">

            <C:forEach items="${list}" var="u">
                <ul class="list_b">
                    <li class="b20"><label><span>${u.name}</span></li>
                    <li class="b20"><label>${u.sort}</label></li>
                    <li class="b20"><label><fmt:formatDate value="${u.crtime}" pattern="yyyy-MM-dd"/></label></li>
                    <li class="b20"><label><fmt:formatDate value="${u.uptime}" pattern="yyyy-MM-dd"/></label></li>
                    <li class="b20"><label><a class="edit_btn df_btn fl abj" onclick="showUserEdit(${u.id})">编辑</a>
                        <a href="${pageContext.request.contextPath}/deLanMu?id=${u.id}"
                           class="delete_btn df_btn fl abj">删除</a></label></li>
                </ul>

            </C:forEach>

        </div>

        <div class="pull_page">
            <div class="fl pull_page_up">上一页</div>
            <ul>
                <li class="on">1</li>
                <li>2</li>
                <li>3</li>
                <li>4</li>
                <li class="pull_page_df_btn">…</li>
                <li>12</li>
            </ul>
            <div class="fl pull_page_down">下一页</div>
        </div>


    </div>
</div>


<!-- 添加栏目 -->
<form action="<%=request.getServletContext().getContextPath()%>/addLanMu" method="post">
    <div class="add_Account dn" id="add_column">
        <div class="add_Account_c">
            <div class="add_Account_h">
                <div class="add_Account_h_in">
                    添加栏目
                    <span class="fr add_Account_close"><img src="${pageContext.request.contextPath}/images/close.png"></span>
                </div>
            </div>
            <div class="user_name user_i">
                <label>栏目名</label> <input type="text" placeholder="输入栏目名" name="userName">
            </div>
            <div class="user_password user_i">
                <label>序<i>调</i>号</label> <input type="text" placeholder="输入序号" name="userSort">
            </div>
            <input class="add_Account_ok_btn text_center" id="add_Account_ok_btn" type="submit" value="确定"
                   class="login_btn" style="margin-left: 40px">
        </div>
    </div>
</form>

<!-- 编辑栏目 -->
<div class="add_Account dn" id="user_column" >
    <form action="<%=request.getServletContext().getContextPath()%>/updateLanMu" method="post">
        <input type="hidden" name="id" id="userid"/>
        <div class="add_Account_c">
            <div class="add_Account_h">
                <div class="add_Account_h_in">
                    编辑栏目
                    <span class="fr add_Account_close"><img src="${pageContext.request.contextPath}/images/close.png"></span>
                </div>
            </div>
            <div class="user_name user_i">
                <label>栏目名</label> <input type="text" placeholder="输入栏目名" name="userName" id="userName">
            </div>
            <div class="user_password user_i">
                <label>序<i>调</i>号</label> <input type="text" placeholder="输入序号"  name="userSort" id="userSort">
            </div>
            <button class="add_Account_ok_btn text_center" type="submit">确<i>皮</i>定</button>
        </div>
    </form>
</div>

<!-- 删除栏目 -->
<div class="add_Account dn" id="delete_column">
    <div class="add_Account_c">
        <div class="add_Account_h">
            <div class="add_Account_h_in">
                删除栏目
                <span class="fr add_Account_close"><img src="${pageContext.request.contextPath}/images/close.png"></span>
            </div>
        </div>
        <div class="delete_text">确定删除“ <span>jiaopwuchu</span> ”栏目吗？</div>
        <div class="add_Account_ok_btn text_center" id="delete_column_ok_btn">确<i>皮</i>定</div>
    </div>
</div>


</body>
<script type="text/javascript" src="${pageContext.request.contextPath}/newjs/jquery.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/newjs/main.js"></script>
<script type="text/javascript">

    function showUserEdit(id) {
        $.ajax({
            type: "get",
            url: "${pageContext.request.contextPath}/getLanMu?id=" + id,
            success: function (rs) {
                console.log(rs);
                var user = JSON.parse(rs);
                console.log(user);
                // $("#editeuseracct").html(user.acct);
                $("#userName").val(user.name);
                $("#userSort").val(user.sort);
                $("#userid").val(user.id);

            }
        });


        $("#user_column").show();
    }

</script>
</html>